unit IntUseBar;

interface

uses DGLE, DGLE_Types, Engine;

type
  TIntUseBar = class(TObject)
  private
    pUseBar: ITexture;
    FLeft: Integer;
    FTop: Integer;
    procedure SetLeft(const Value: Integer);
    procedure SetTop(const Value: Integer);
  public
    constructor Create;  
    destructor Destroy; override;
    procedure Render();
    function MouseOver(): Boolean;
    property Top: Integer read FTop write SetTop;
    property Left: Integer read FLeft write SetLeft;
  end;


implementation

{ TIntUseBar }

constructor TIntUseBar.Create;
begin
  pResMan.Load('Resources\Sprites\Interface\UseBar.png', IEngineBaseObject(pUseBar), TEXTURE_LOAD_DEFAULT_2D);
end;

destructor TIntUseBar.Destroy;
begin
  pUseBar := nil;
  inherited;
end;

function TIntUseBar.MouseOver: Boolean;
begin
  Result := (MousePos.X > Left) and (MousePos.X < Left + 331) and (MousePos.Y > Top) and (MousePos.Y < Top + 35);
end;

procedure TIntUseBar.Render;
begin
  Left := SCREEN_WIDTH div 2 - 165;
  Top := SCREEN_HEIGHT - 38;
  pRender2D.DrawTexture(pUseBar, Point2(Left, Top), Point2(331, 35));
end;

procedure TIntUseBar.SetLeft(const Value: Integer);
begin
  FLeft := Value;
end;             

procedure TIntUseBar.SetTop(const Value: Integer);
begin
  FTop := Value;
end;

end.
